/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.esi.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.esi.entity.EsiElecDynamic;
import com.jeesite.modules.esi.service.EsiElecDynamicService;

/**
 * esi_elec_dynamicController
 * @author xyde
 * @version 2020-03-09
 */
@Controller
@RequestMapping(value = "${adminPath}/esi/esiElecDynamic")
public class EsiElecDynamicController extends BaseController {

	@Autowired
	private EsiElecDynamicService esiElecDynamicService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public EsiElecDynamic get(String id, boolean isNewRecord) {
		return esiElecDynamicService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("esi:esiElecDynamic:view")
	@RequestMapping(value = {"list", ""})
	public String list(EsiElecDynamic esiElecDynamic, Model model) {
		model.addAttribute("esiElecDynamic", esiElecDynamic);
		return "modules/esi/esiElecDynamicList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("esi:esiElecDynamic:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<EsiElecDynamic> listData(EsiElecDynamic esiElecDynamic, HttpServletRequest request, HttpServletResponse response) {
		esiElecDynamic.setPage(new Page<>(request, response));
		Page<EsiElecDynamic> page = esiElecDynamicService.findPage(esiElecDynamic);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("esi:esiElecDynamic:view")
	@RequestMapping(value = "form")
	public String form(EsiElecDynamic esiElecDynamic, Model model) {
		model.addAttribute("esiElecDynamic", esiElecDynamic);
		return "modules/esi/esiElecDynamicForm";
	}

	/**
	 * 保存esi_elec_dynamic
	 */
	@RequiresPermissions("esi:esiElecDynamic:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated EsiElecDynamic esiElecDynamic) {
		esiElecDynamicService.save(esiElecDynamic);
		return renderResult(Global.TRUE, text("保存esi_elec_dynamic成功！"));
	}
	
	/**
	 * 删除esi_elec_dynamic
	 */
	@RequiresPermissions("esi:esiElecDynamic:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(EsiElecDynamic esiElecDynamic) {
		esiElecDynamicService.delete(esiElecDynamic);
		return renderResult(Global.TRUE, text("删除esi_elec_dynamic成功！"));
	}
	
}